<template>
  <div>
    <el-tree
        :data="data"
        show-checkbox
        node-key="id"
        :props="defaultProps"
        @check="handleNodeClick"
    />
  </div>
</template>
<script>

import axios from "axios";

export default {
  name: "depttree",

  data() {
    return {
      data:[],
      defaultProps: {
        children: 'children',
        label: 'name',
      },
    }
  },
  methods: {
    //获取角色
    getcomanyuser() {
      axios.get('/getcomanyuser').then(res => {
        console.log(res);
        this.data = res.data.list
      })
    },
    handleNodeClick(val1, status) {
      this.checkdvalues = []
      let list = status['checkedNodes']
      for (var i = 0; i < list.length; i++) {
        if (list[i]['type'] == 3) {
          this.checkdvalues.push(list[i]['id'])
        }
      }
      this.$emit('setids', this.checkdvalues)
    },
  },
  mounted() {
    this.getcomanyuser()
  }
}
</script>

<style scoped>

</style>
